import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/ManageRoles/GetRolesList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}


export const getDetail = (id) => {
  return request({
    // url: '/api/school-service/school/detail',
    url: '/api/ManageRoles/GetRoleInfo',
    method: 'get',
    params: {
      id
    }
  })
}

//获取菜单权限列表
export const grantTree = () => {
  return request({
    url: '/api/ManageRoles/GetMenuPermission',
    method: 'get',
  })
}

// 修改角色的菜单权限
export const grant = (roleIds, menuIds, dataScopeIds) => {
  return request({
    url: '/api/ManageRoles/EditRoleMenuPermission',
    method: 'post',
    data: {
      roleIds,
      menuIds,
      dataScopeIds
    }
  })
}

export const remove = (params) => {
  return request({
    url: '/api/ManageRoles/DelRole',
    method: 'post',
    data:params
    // params: {
    //   ids,
    // }
  })
}

export const add = (row) => {
  return request({
    url: '/api/ManageRoles/AddOrEditRole',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/ManageRoles/AddOrEditRole',
    method: 'post',
    data: row
  })
}


// 获取角色拥有的菜单权限列表
export const getRole = (roleIds) => {
  return request({
    url: '/api/ManageRoles/GetRoleMenuPermission',
    method: 'get',
    params: {
      roleIds,
    }
  })
}

// 上级角色
export const getRoleTree = (roleIds) => {
  return request({
    url: '/api/ManageRoles/GetParentRoleList',
    method: 'get',
    params: {
      roleIds,
    }
  })
}
